package com.kws.system.controller.merchant;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.common.core.domain.R;
import com.kws.system.domain.merchant.MerchantExamineRq;
import com.kws.system.domain.merchant.QueryDeviceAuditRq;
import com.kws.system.domain.merchant.info.QueryDeviceAuditInfo;
import com.kws.system.domain.merchant.info.QueryDeviceInfo;
import com.kws.system.service.merchant.DeviceAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <b>DeviceAuditController</b>
 *
 * @description: DeviceAuditController <br>
 * @date: 2024/12/5 14:06 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "商品上架管理")
@RestController
public class DeviceAuditController {
    private static final Logger logger = LoggerFactory.getLogger(DeviceAuditController.class);

    @Autowired
    private DeviceAuditService deviceAuditService;

    @ApiOperation("分页查询商品上架审核列表")
    @PostMapping("/query/deviceAudit/page")
    public R<Page<QueryDeviceAuditInfo>> queryDeviceAuditPage(@RequestBody QueryDeviceAuditRq rq){
        Page<QueryDeviceAuditInfo> pageInfo = deviceAuditService.queryDeviceAuditPage(rq);
        return R.ok(pageInfo);
    }

    @ApiOperation("根据设备ID查询设备详情")
    @GetMapping("/query/deviceAudit/byId")
    public R<QueryDeviceInfo> queryDeviceAuditById(@RequestParam Long id){
        QueryDeviceInfo info = deviceAuditService.queryDeviceAuditById(id);
        return R.ok(info);
    }

    @ApiOperation("根据设备ID删除设备信息")
    @GetMapping("/delete/deviceAudit/byId")
    public R deleteDeviceById(@RequestParam Long id){
        boolean status = deviceAuditService.deleteDeviceById(id);
        return R.ok(status);
    }

    @ApiOperation("设备一审")
    @PostMapping("/deviceAudit/firstInstance")
    public R deviceAuditFirstInstance(@RequestBody MerchantExamineRq rq){
        boolean status = deviceAuditService.deviceAuditFirstInstance(rq);
        return R.ok(status);
    }

    @ApiOperation("设备二审")
    @PostMapping("/deviceAudit/secondInstance")
    public R deviceAuditSecondInstance(@RequestBody MerchantExamineRq rq){
        boolean status = deviceAuditService.deviceAuditSecondInstance(rq);
        return R.ok(status);
    }
}
